package com.duanjc.mergemd.bean;



import com.duanjc.mergemd.utils.FileFormatUtils;

import java.io.Serializable;
import java.util.Objects;

/**
 * 本类用于封装 txt 文件内容
 *
 * @author cqh
 * @date 2022/03/13 17:50
 */
public class DocumentContent implements Serializable {
    private static final long serialVersionUID = 6572019257295729L;

    /**
     * 文件后缀
     */
    private String suffix = ".md";

    /**
     * 源路径
     */
    private String srcPath;

    /**
     * 目标路径
     */
    private String destPath;

    /**
     * 当选择合并成一个文件时，在插入第insert个文件前加入[TOC]
     */
    private int insert = 1;

    /**
     * 当选择合并成多个文件时，生成的文件名为指定层次下的目录名
     * 参考 {@link MergeToMultipleFile#level}
     */
    private int level = 1;

    /**
     * 有两个值：0、1，分别代表不同操作含义，据此生成不同的实例
     * <p>0：合并成一个文件
     * <p>1：合并成多个文件
     */
    private int choose = 0;

    @Override
    public String toString() {
        return "DocumentContent{" +
                "suffix='" + suffix + '\'' +
                ", srcPath='" + srcPath + '\'' +
                ", destPath='" + destPath + '\'' +
                ", insert=" + insert +
                ", level=" + level +
                ", choose=" + choose +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) { return true;}
        if (o == null || getClass() != o.getClass()) {return false;}
        DocumentContent that = (DocumentContent) o;
        return insert == that.insert && level == that.level && choose == that.choose
                && Objects.equals(suffix, that.suffix) && Objects.equals(srcPath, that.srcPath)
                && Objects.equals(destPath, that.destPath);
    }

    @Override
    public int hashCode() {
        return Objects.hash(suffix, srcPath, destPath, insert, level, choose);
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getSrcPath() {
        return srcPath;
    }

    public void setSrcPath(String srcPath) {
        this.srcPath = srcPath;
    }

    public String getDestPath() {
        return destPath;
    }

    public void setDestPath(String destPath) {
        this.destPath = destPath;
    }

    public int getInsert() {
        return insert;
    }

    public void setInsert(String insert) {
        this.insert = FileFormatUtils.parseToInt(insert);
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = FileFormatUtils.parseToInt(level);
    }

    public int getChoose() {
        return choose;
    }

    public void setChoose(String choose) {
        this.choose = FileFormatUtils.parseToInt(choose);
    }
}
